/**
* @author:kellen
* @contact:xiekellen@hotmail.com
* @company:achivo-gz
* @created on:
* @modified on:
*/

package com.sasis.dao.ibatis;

import java.util.List;

import com.sasis.dao.ibatis.BaseDaoiBATIS;
import com.sasis.model.FlightTransferLuggage;
import com.sasis.dao.FlightTransferLuggageDao;

import org.springframework.orm.ObjectRetrievalFailureException;

public class FlightTransferLuggageDaoiBatis extends BaseDaoiBATIS implements FlightTransferLuggageDao {

    /**
     * @see com.sasis.dao.FlightTransferLuggageDao#getFlightTransferLuggages(com.sasis.model.FlightTransferLuggage)
     */
    public List getFlightTransferLuggages(final FlightTransferLuggage flightTransferLuggage) {
          return getSqlMapClientTemplate().queryForList("getFlightTransferLuggages", flightTransferLuggage);
    }

    /**
     * @see com.sasis.dao.FlightTransferLuggageDao#getFlightTransferLuggage(Integer id)
     */
    public FlightTransferLuggage getFlightTransferLuggage(Integer id) {
        FlightTransferLuggage flightTransferLuggage = (FlightTransferLuggage) getSqlMapClientTemplate().queryForObject("getFlightTransferLuggage", id);

        //if (flightTransferLuggage == null) {
            //throw new ObjectRetrievalFailureException(FlightTransferLuggage.class, id);
        //}

        return flightTransferLuggage;
    }

    /**
     * @see com.sasis.dao.FlightTransferLuggageDao#saveFlightTransferLuggage(FlightTransferLuggage flightTransferLuggage)
     */    
    public int saveFlightTransferLuggage(final FlightTransferLuggage flightTransferLuggage) {
        Integer id = flightTransferLuggage.getId();
        // check for new record
        if (id == null) {
            id = (Integer) getSqlMapClientTemplate().insert("addFlightTransferLuggage", flightTransferLuggage);
        } else {
            getSqlMapClientTemplate().update("updateFlightTransferLuggage", flightTransferLuggage);
        }
        if( id == null ) {
            throw new ObjectRetrievalFailureException(FlightTransferLuggage.class, id);
        }
        return id.intValue();
    }

    /**
     * @see com.sasis.dao.FlightTransferLuggageDao#removeFlightTransferLuggage(Integer id)
     */
    public void removeFlightTransferLuggage(FlightTransferLuggage flightTransferLuggage) {
        getSqlMapClientTemplate().update("deleteFlightTransferLuggage",  flightTransferLuggage);
    }
}
